package cn.ac.iscas.dao.impl.mysql;

import cn.ac.iscas.dao.IComponentMetadataDao;
import cn.ac.iscas.dao.condition.MysqlDataSourceCondition;
import cn.ac.iscas.dao.entity.ComponentMetadataDO;
import cn.ac.iscas.dao.mapper.mysql.IMysqlComponentMetadataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author LJian
 * @version 1.0
 * @description: TODO
 * @date 2023/1/13 18:12
 */
@Component
@Conditional(MysqlDataSourceCondition.class)
public class MysqlComponentMetadataDao implements IComponentMetadataDao {
    @Autowired
    IMysqlComponentMetadataMapper componentMetadataMapper;

    public List<ComponentMetadataDO> selectAll(){
        return componentMetadataMapper.selectAll();
    }

    public List<ComponentMetadataDO> select(final String type, final String modelType) {
        return componentMetadataMapper.select(type, modelType);
    }

    @Override
    public List<ComponentMetadataDO> selectByCategory(String category) {
        return componentMetadataMapper.selectByCategory(category);
    }

    public int save(ComponentMetadataDO componentMetadata) {
        return componentMetadataMapper.insert(componentMetadata);
    }

    public ComponentMetadataDO selectById(String id) {
        return componentMetadataMapper.selectById(id);
    }

    public int deleteByIds(List<String> ids) {
        return componentMetadataMapper.deleteBatch(ids);
    }
}
